<template>
    <div class="row">
        <el-checkbox v-model="comp.enabled">{{ comp.__classname__ }}</el-checkbox>
        <el-button round size="small" :icon="Document" @click="gm.toConsole(comp)"></el-button>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>Content</el-text>
        <el-input size="small" type="textarea" v-model="comp.string" />
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>Placeholder</el-text>
        <el-input size="small" v-model="comp.placeholder" />
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>TextLabel</el-text>
        <el-input size="small" disabled :value="gm.targetName(comp.textLabel)" />
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>PlaceholderLabel</el-text>
        <el-input size="small" disabled :value="gm.targetName(comp.placeholderLabel)" />
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>BackgroundImage</el-text>
        <el-input size="small" disabled :value="gm.targetName(comp.backgroundImage)" />
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>InputFlag</el-text>
        <el-select v-model="comp.inputFlag" size="small">
            <el-option v-for="item in inputFlag.__enums__" :key="item.value" :label="item.name" :value="item.value" />
        </el-select>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>InputMode</el-text>
        <el-select v-model="comp.inputMode" size="small">
            <el-option v-for="item in inputMode.__enums__" :key="item.value" :label="item.name" :value="item.value" />
        </el-select>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>ReturnType</el-text>
        <el-select v-model="comp.returnType" size="small">
            <el-option v-for="item in returnType.__enums__" :key="item.value" :label="item.name" :value="item.value" />
        </el-select>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>MaxLength</el-text>
        <el-input-number size="small" :controls="false" :step="0.1" v-model="comp.maxLength" />
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>TabIndex</el-text>
        <el-input-number size="small" :controls="false" :step="0.1" v-model="comp.tabIndex" />
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>EditingDidBegan</el-text>
    </div>
    <div class="span-left-20" v-for="data in gm.toEvents(comp.editingDidBegan)">
        <el-breadcrumb :separator-icon="ArrowRight">
            <el-breadcrumb-item>{{ data.target }}</el-breadcrumb-item>
            <el-breadcrumb-item>{{ data.component }}</el-breadcrumb-item>
            <el-breadcrumb-item>{{ data.handler }}</el-breadcrumb-item>
            <el-breadcrumb-item>{{ data.customEventData }}</el-breadcrumb-item>
        </el-breadcrumb>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>TextChanged</el-text>
    </div>
    <div class="span-left-20" v-for="data in gm.toEvents(comp.textChanged)">
        <el-breadcrumb :separator-icon="ArrowRight">
            <el-breadcrumb-item>{{ data.target }}</el-breadcrumb-item>
            <el-breadcrumb-item>{{ data.component }}</el-breadcrumb-item>
            <el-breadcrumb-item>{{ data.handler }}</el-breadcrumb-item>
            <el-breadcrumb-item>{{ data.customEventData }}</el-breadcrumb-item>
        </el-breadcrumb>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>EditingDidEnded</el-text>
    </div>
    <div class="span-left-20" v-for="data in gm.toEvents(comp.editingDidEnded)">
        <el-breadcrumb :separator-icon="ArrowRight">
            <el-breadcrumb-item>{{ data.target }}</el-breadcrumb-item>
            <el-breadcrumb-item>{{ data.component }}</el-breadcrumb-item>
            <el-breadcrumb-item>{{ data.handler }}</el-breadcrumb-item>
            <el-breadcrumb-item>{{ data.customEventData }}</el-breadcrumb-item>
        </el-breadcrumb>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>EditingReturn</el-text>
    </div>
    <div class="span-left-20" v-for="data in gm.toEvents(comp.editingReturn)">
        <el-breadcrumb :separator-icon="ArrowRight">
            <el-breadcrumb-item>{{ data.target }}</el-breadcrumb-item>
            <el-breadcrumb-item>{{ data.component }}</el-breadcrumb-item>
            <el-breadcrumb-item>{{ data.handler }}</el-breadcrumb-item>
            <el-breadcrumb-item>{{ data.customEventData }}</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
</template>

<script lang="ts" setup>
import { Document, ArrowRight } from '@element-plus/icons-vue'
import gm from './gm';

defineProps<{
    comp: CCComponent,
    update: Number,
}>()
const box = cc.EditBox || cc.EditBoxComponent
const inputFlag = box.InputFlag
const inputMode = box.InputMode
const returnType = box.KeyboardReturnType
</script>